#include "trie.h"

int main()
{
    Trie *t = trieCreate();
    char s[30];

    int opt = 1;
    while (opt)
    {
        printf("option input: 0.exit 1.insert 2.search 3.start with\n");
        scanf("%d", &opt);

        switch (opt)
        {
        case 0:
            goto exit;

        case 1:
            printf("insert:\n");
            scanf("%s", s);
            trieInsert(t, s);
            break;

        case 2:
            printf("search:\n");
            scanf("%s", s);
            printf((trieSearch(t, s) ? "success\n" : "fail\n"));
            break;

        case 3:
            printf("start with:\n");
            scanf("%s", s);
            printf((trieStartWith(t, s) ? "success\n" : "fail\n"));
            break;
        }
    }
exit:
    trieFree(t);
    return 0;
}